﻿using ControlCore;
using ControlCore.Device;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace VirtualDeviceV1
{
    [Export(typeof(IDevice))]
    [ExportMetadata("Name", "Virtual device")]
    public class VirtualDeviceV1 : IDevice
    {
        private readonly VisualOutput visualOutput;

        public VirtualDeviceV1()
        {
            visualOutput = new VisualOutput();
        }

        public bool IsInitialized { get; private set; }

        public void Init()
        {
            this.visualOutput.ChangeText("Init done");
            IsInitialized = true;
        }

        public void Close()
        {
            this.visualOutput.ChangeText("Shutdown");
            IsInitialized = false;
        }

        public FrameworkElement DeviceOutput
        {
            get { return this.visualOutput; }
        }


        public void SendCommand(ControlCommand controlCommand, double value)
        {
            this.visualOutput.ChangeText("Received command :" 
                + Environment.NewLine 
                + controlCommand
                + " -> " + value);
        }
    }
}
